<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <script th:fragment="js" type="text/javascript" th:inline="text">
        /*<![CDATA[*/
        /**
         * Created by 张乐平 on 8/2 0002.
         */

        jQuery(function () {

            $('#myModal').modal('hide');

            $('#myModal').on('hide.bs.modal', function () {
                //alert('嘿，我听说您喜欢模态框...');
            })
        });

        var confirmDelUser = function (userName, userId) {
            $("#delUserName").text(userName);
            $("#myModal-del").modal("show");
            $("#doDel").one("click", function () {
                window.location = "./users/del/" + userId;
            });
        };

        var showUser = function (userId) {
            $.ajax({
                type: "get",
                url: "./users/" + userId,
                dataType: "json",
                async: true,
                success: function (data) {
                    $("#addUserName-update").val(data.addUserName);
                    $("#userId").val(data.userId);
                    $("#pwd-update").val(data.password);
                    $("#pwd2-update").val(data.password2);
                    var chkRoles = $("#roles").find("input");
                    $(chkRoles).each(function (i, e) {
                        var echk = e;
                        $(echk).prop("checked", false);
                        $(data.roles).each(function (i, e) {
                            if ($(echk).val() == e) {
                                $(echk).prop("checked", true);
                            }
                        });
                    });
                    $("#myModal-update").modal("show");
                }
            });
        };

        /*]]>*/
    </script>
</head>
</html>